package com.demo.io;

import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class CharStreamTest {
    public static void main(String[] args) throws IOException {
        // 写字符
        FileWriter fw = new FileWriter("test.txt");
        fw.write("hello world");
        fw.close();
        // 读
        FileReader fr = new FileReader("db.sql");
        char[] chars = new char[1000];
        // 读取内容到字符数组 ，并获取读取内容长度
        int readLen = fr.read(chars);
        fr.close();
        //
        System.out.println(new String(chars,0,readLen));
    }
}
